home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Networking / ATP Demo 1.0 / ATP Demo.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-28  |  6.4 KB  |  245 lines  |  [TEXT/MPS ]

  1. /*****************************************************************
  2.  
  3.     Program:    < ATP Demo >
  4.     File:        < ATP Demo.h >
  5.     
  6.     Written by  Scott Kuechle
  7.     of <Apple Macintosh Developer Technical Support>
  8.     
  9.     10/92 SRK created
  10.     8/94 SRK Modified to use a queue of parameter
  11.              blocks.
  12.  
  13.     Copyright © 1992, 1994 Apple Computer, Inc.
  14.     All rights reserved.
  15.     
  16. *****************************************************************/
  17.  
  18.  
  19. #include    <types.h>
  20. #include    <quickdraw.h>
  21. #include    <toolutils.h>
  22. #include    <fonts.h>
  23. #include    <events.h>
  24. #include    <windows.h>
  25. #include    <dialogs.h>
  26. #include    <menus.h>
  27. #include    <desk.h>
  28. #include    <textedit.h>
  29. #include    <scrap.h>
  30. #include    <segload.h>
  31. #include    <osevents.h>
  32. #include    <files.h>
  33. #include    <devices.h>
  34. #include    <memory.h>
  35. #include    <appletalk.h>
  36. #include    <lists.h>
  37. #include    <SysEqu.h>
  38. #include    <Script.h>
  39. #include    <CursorCtl.h>
  40. #include    <Resources.h>
  41. #include    <ADSP.h>
  42. #include    <Packages.h>
  43. #include    <String.h>
  44. #include    <Strings.h>
  45. #include    <Traps.h>
  46. #include    <GestaltEqu.h>
  47. #include    <Errors.h>
  48.  
  49.  
  50. typedef short SICN[16];
  51. typedef SICN *SICNList;
  52. typedef SICNList *SICNHand;
  53.  
  54.  
  55.  
  56. /* 1.01 - kMinHeap - This is the minimum result from the following
  57.      equation:
  58.             
  59.             ORD(GetApplLimit) - ORD(ApplicZone)
  60.             
  61.      for the application to run. It will insure that enough memory will
  62.      be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  63.      application, and still give the application some 'breathing room'.
  64.      To derive this number, we ran under a MultiFinder partition that was
  65.      our requested minimum size, as given in the 'SIZE' resource. */
  66.      
  67. #define        kMinHeap                (29 * 1024)
  68. #define        kMinSpace                (20 * 1024)
  69.  
  70. #define        _WaitNextEvent            0xA860
  71. #define        _Unimplemented            0xA89F
  72.  
  73. /* For System 7.0 */
  74. #define     _Gestalt                 0xA1AD
  75.  
  76. #define        appleID                    128             /* This is a resource ID */
  77. #define        fileID                     129             /* ditto */
  78. #define        editID                     130             /* ditto */
  79.  
  80. #define     extremeNeg                -32768
  81. #define     extremePos                32767 - 1            /* required for old region bug */
  82.  
  83. #define        osEvent                    app4Evt        /* event used by MultiFinder */
  84. #define        resumeMask                1            /* bit of message field for resume vs. suspend */
  85. #define        sysEnvironsVersion        1
  86.  
  87. #define        kATPTimeOutVal            3            /* re-try ATP SendRequest every 3 seconds */
  88. #define        kATPRetryCount            5            /* for five times */
  89. #define        kZonesSize                578            /* size of buffer for zone names */
  90. #define        kGetZoneList            8            /* the Zone Information Protocol socket */
  91. #define        kZIPSocket                6            /* the Zone Information Protocol socket */
  92. #define        kMoreZones                0xFF000000     /* mask to see if more zones to come */
  93. #define        kZoneCount                0x0000FFFF     /* mask to count zones in buffer */
  94. #define        kHilite                    1            /* hilite value for button control */
  95. #define        kDeHilite                0            /* dehilite value for button control */
  96. #define     theBridgeSocket         0x6
  97.  
  98. /* 
  99.  *    constants for window activation 
  100.  */
  101. #define     kActivateWindow            1
  102. #define     kDeactivateWindow        0
  103.  
  104. #define        maxZones                250                /* max. number of zones we can save in our buffer */
  105. #define        ZoneBufSize                maxZones * 33    /* our ugly, mondo zone buffer */
  106. #define        BigLookupBuffer            10000            /* another big, ugly buffer - for nbp lookups */
  107.  
  108.  
  109. // ------------------------------------------------
  110.  
  111. #define     rMenuBar                 128                    /*application's menu bar*/
  112.  
  113. #define        ZoneMenuID                220
  114. #define        TypeMenuID                221
  115. #define        ObjectMenuID            222
  116. #define        DataSizeMenuID            223
  117.  
  118. #define     rAboutDialog              128                    /*about alert*/
  119. #define     rDialog                  129                    /*application's window*/
  120. #define     rErrorDialog              130                    /*error alert window*/
  121.  
  122.     /* The following constants are used to identify menus and their items. The menu IDs*/
  123.     /* have an "m" prefix and the item numbers within each menu have an "i" prefix.*/
  124. #define     mApple                  128                    /*Apple menu*/
  125. #define     iAbout                  1
  126.  
  127. #define     mFile                      129                    /*File menu*/
  128. #define     iClose                  1
  129. #define     iQuit                      2
  130.  
  131. #define     mEdit                      130                    /*Edit menu*/
  132. #define     iUndo                      1
  133. #define     iCut                      3
  134. #define     iCopy                      4
  135. #define     iPaste                  5
  136. #define     iClear                  6
  137.  
  138. #define     mRequestOptions          131                    /*Request Options menu*/
  139. #define     iReqClockTime              1
  140. #define     iReqData                  2
  141. #define     iSingleRequest          4
  142. #define     iMultipleRequests          5
  143.  
  144. #define     kStandardTriSICN          -3990
  145.  
  146.  
  147. /* dialog items */
  148.  
  149. #define     kobjectItemID             1
  150. #define     ktypeItemID              2
  151. #define     kMoofFilterCheckBox        3
  152. #define     kzoneItemID              4
  153. #define     kPopupBorderID            8
  154. #define     kClockTime                9
  155. #define     kClockTimeBorder        11
  156. #define     kReqDataButton            10
  157. #define     kStatusText                12
  158.  
  159.  
  160. /* our error message codes */
  161.  
  162. #define     atalkErr                1
  163. #define     memErr                    2
  164. #define     menuErr                    3
  165. #define     nbpErr                    4
  166. #define     noTargetErr                5
  167. #define     badROMsErr                6
  168. #define     heapErr                    7
  169. #define     noMemErr                8
  170. #define     DrvrErr                    9
  171. #define     SktErr                    10
  172. #define     RsrcErr                    11
  173. #define     dataNotValidErr            12
  174. #define     dataIsValid                13
  175.  
  176.  
  177.     /* our test data resource definitions */
  178. #define     kTestDataRsrcID            128
  179. #define     kTestDataType            'test'
  180.  
  181.  
  182. /* defines for req/resp packet */
  183.  
  184. #define     maxQElements            10
  185.  
  186.     /* our request command codes */
  187. #define        kSendTime                1
  188. #define        kSendData                2
  189.  
  190. #define        kMaxPacketSize            578        /* max. size for atp data is 578 bytes */
  191. #define        kMaxResponses            8        /* maximum number of responses we expect */
  192. #define        kRespBufSize            kMaxPacketSize * kMaxResponses    /* our response buffer */
  193.  
  194. #define        kSendReqBtnText            "\pSend Request"
  195. #define        kStopReqBtnText            "\pStop Requests"
  196.  
  197. #define        kTestDataCorrect        "\pTest data received is correct!"
  198. #define        kTestDataIncorrect        "\pTest data received is not correct."
  199. #define        kBlankText                "\p                                  "
  200.  
  201. #define        kMaxBDSElements            8    /* from the header file def. for BDSElement */
  202.  
  203. struct ourRespBuf
  204. {
  205.     char buf[kRespBufSize];
  206. };
  207. typedef struct ourRespBuf ourRespBuf;
  208.  
  209. struct ourReqData
  210. {
  211.     char data[kMaxPacketSize];
  212. };
  213. typedef struct ourReqData ourReqData;
  214.  
  215. #define myPrivateFields \
  216.     OSErr            functionResult;\
  217.     Ptr                reqData;\
  218.     Ptr                respData;\
  219.     Ptr                bdsPtr;    \
  220.     long             myA5;\
  221.     ProcPtr            ourCompletion;
  222.  
  223. struct ourParamBlockFields
  224. {
  225.     myPrivateFields
  226. };
  227. typedef struct ourParamBlockFields ourParamBlockFields;
  228.     
  229. #define    kOurPBNegOffset    sizeof(ourParamBlockFields)
  230.  
  231.     /* our parameter block structure - Note that
  232.         the "myA5" and "ourCompletion" fields must
  233.         remain 4 & 8 bytes above the atp pb. If you
  234.         change this, you must change our assembly
  235.         routine "PreCompletion" */
  236. struct myATPParamBlock
  237. {
  238.     myPrivateFields
  239.     ATPParamBlock     u;
  240. };
  241. typedef struct myATPParamBlock myATPParamBlock;
  242. typedef struct myATPParamBlock *myATPParamBlockPtr;
  243.  
  244.  
  245. #define    atpEntityFilter        "\patp"